package com.aaa.web.service.impl.secondcarserviceimpl;

import com.aaa.entity.Employee;
import com.aaa.entity.secondcar.SecondCarDetailMessage;
import com.aaa.entity.secondcar.SecondCarRelatedMessage;
import com.aaa.util.EmpUtil;
import com.aaa.web.commons.Result;
import com.aaa.web.commons.SecondCarVerifyQuery;
import com.aaa.web.dao.secondcardao.SecondCarverifyDao;
import com.aaa.web.service.secondcarservice.SecondCarVerifyService;
import com.aaa.web.systemconst.ISystemConst;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @program: ${PROJECT_NAME}
* @description: 二手车认证页面
* @author:
* @create: 10:32 2019/1/3
**/
@Service
public class SecondCarServiceImpl implements SecondCarVerifyService {

    /**自动注入dao层*/
    @Autowired
    private SecondCarverifyDao dao;
    /**查询所有二手车相关信息展现在认证信息栏*/
    @Override
    public Map getSecondCarRelatedMessage(SecondCarVerifyQuery query) {
        int page=query.getPage();
        int size=query.getLimit();
        PageHelper.startPage(page,size);
        //获取登录员工
        Employee emp= EmpUtil.getEmp();
        query.setEmpschoolid(emp.getSchoolid());
        //存放返回信息的map
        Map m = new HashMap();
        //查询所有信息
        List list = dao.getSecondCarRelatedMessage(query);
        m.put("data",list);
        m.put("count",dao.getSecondCarRelatedCount(query));
        m.put("code",ISystemConst.SU_COD);
        m.put("msg","");
        return m;
    }
    /**二手车认证的详情表单*/
    @Override
    public List<SecondCarDetailMessage> getSecondCarDetailMessage(SecondCarRelatedMessage s) {

        List list=dao.getSecondCarDetailMessage(s);
        return list;
    }
    /**二手车门店认证*/
    @Override
    public Result verifySecondCar(SecondCarDetailMessage s) {
        //获取员工schoolid
        Employee emp=EmpUtil.getEmp();
        //设置返回值
        Result result=new Result();
        //执行操作
        dao.verifySecondCar(s);
        result.setCode(ISystemConst.SUCCESS_CODE);
        return result;
    }
    /**取消二手车门店认证*/
    @Override
    public Result cancelVerification(SecondCarRelatedMessage s) {
        //获取员工schoolid
        Employee emp=EmpUtil.getEmp();
        //设置返回值
        Result result=new Result();
        dao.cancelVerification(s);
        result.setCode(ISystemConst.SUCCESS_CODE);
        return result;
    }
    /**删除二手车信息*/
    @Override
    public void deleteSecondCarMessage(SecondCarRelatedMessage s) {
        dao.deleteSecondCarMessage(s);
    }
}
